OPC Studio User's Guide and Reference
Data Types in OPC-UA
Concepts > Development Concepts > Development Advanced Topics > Data Types in OPC > Data Types in OPC-UA

OPC Unified Architecture has its own type system, based on a set of built-in types, and a type graph that supports inheritance and creation of structured types.

The types in Microsoft .NET are different, and all data is represented using an Object type and its derivatives. Conversions between the two are available, but not always fully possible.

In addition, not everything that can be stored in an Object can later be processed by all .NET tools and languages. Microsoft has created so-called Common Language Specification (CLS), which has certain rules and restrictions that, if followed, guarantee cross-language compatibility.  Public OPC Studio components (assemblies) are fully CLS compliant, and that includes the way the data types are converted to and from OPC types.

If you inspect the conversions, you will notice that most of them have to do with unsigned integer types (except Byte). This is because there are .NET languages that do not have such types, and cannot process them. A typical example of such example in frequent use is VB.NET.

QuickOPC-UA converts data from OPC-UA to .NET according to following table:

OPC-UA type .NET type (Object)
Boolean System.Boolean
Byte System.Byte
ByteString System.Byte[]
DataValue OpcLabs.EasyOpc.UA.UAAttributeData
DateTime System.DateTime (UTC)
Double System.Double
ExpandedNodeId OpcLabs.EasyOpc.UA.AddressSpace.UANodeId
ExtensionObject

when the OPC UA Complex Data extension is enabled (the default): UAGenericObject Class

when the OPC UA Complex Data extension is disabled: OpcLabs.EasyOpc.UA.UAExtensionObject

Float System.Single
Guid System.Guid
Int16 System.Int16
Int32 System.Int32
Int64 System.Int64
LocalizedText System.String (see note)
NodeId OpcLabs.EasyOpc.UA.AddressSpace.UANodeId
QualifiedName OpcLabs.EasyOpc.UA.AddressSpace.UAQualifiedName
SByte System.Int16
StatusCode OpcLabs.EasyOpc.UA.UAStatusCode
String System.String
UInt16 System.Int32
UInt32 System.Int64
UInt64 System.Decimal
XmlElement System.Xml.XmlElement
array of elementType System.Array of the converted elementType

Note: LocalizedText is converted to its text part.

Types that are highlighted do not convert from OPC-UA to their “natural” .NET counterparts, because the corresponding .NET type is not CLS compliant. Instead, a “wider” type that is CLS compliant is chosen.

Types not listed in the above table at all are not supported.

Strings are internally represented in Unicode.

In QuickOPC-UA for COM, the same types as in QuickOPC-UA for .NET are used. The type conversions between COM and .NET and performed by the Microsoft interoperability layer. Reference to Microsoft documentation for correspondences between the .NET and COM types.

 

If you want to determine the data type of a variable from an OPC UA client, do not use the type of the returned value for that. Instead, read and interpret its DataType attribute (Examples - OPC Unified Architecture - Read DataType attributes ).
See Also

Recommended

Examples - Client OPC Unified Architecture